﻿using UnityEngine;
using System.Collections;

public class IUserInterface : MonoBehaviour {

	public GameObject GetName(string name){
		Transform t = Util.FindChildrRecursion(transform, name);

		if(t == null){
			Debug.Log("get name error:"+ name+":"+ transform.name);
			return null;
		}
		return t.gameObject;
	}

	public GameObject GetName(Transform t, string name){
		Transform r = Util.FindChildrRecursion(t, name);
		
		if(r == null){
			Debug.Log("get name error:"+ name+":"+ transform.name);
			return null;
		}
		return r.gameObject;
	}
    
	public void SetCallBack(string name, UIEventListener.VoidDelegate callBack){

		UIEventListener.Get(this.GetName(name)).onClick += callBack;

	}

	public void SetCallBack(Transform t , string name, UIEventListener.VoidDelegate callBack){

		UIEventListener.Get(this.GetName(t, name)).onClick += callBack;

	}
    public void SetCallBack(GameObject go, UIEventListener.VoidDelegate callBack) {
        UIEventListener.Get(go).onClick += callBack;
    }

}
